import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import dayjs from 'dayjs';
//列表数据
export const columns: BasicColumn[] = [

   {
    title: '月份',
    align:"center",
    sorter: true,
    dataIndex: 'orderDate',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 7 ? text.substr(0,7) : text);
      return text;
    },
   },
  {
    title: '员工' ,
    align:"center",
    dataIndex: 'empId_dictText',
    width: 80,
  },


  {
    title: '合计',
    align:"center",
    dataIndex: 'reserve1'
  },

   {
    title: '基础工资',
    align:"center",
    dataIndex: 'basicSalary'
   },
   {
    title: '全勤',
    align:"center",
    dataIndex: 'fullAttendance'
   },
   {
    title: '扣罚工资',
    align:"center",
    dataIndex: 'deduction'
   },
   {
    title: '其他项',
    align:"center",
    dataIndex: 'other'
   },
   {
    title: '预留',
    align:"center",
    dataIndex: 'reserve2'
   },

   {
    title: '预留',
    align:"center",
    dataIndex: 'reserve3'
   },
   {
    title: '预留',
    align:"center",
    dataIndex: 'reserve4'
   },
   {
    title: '预留',
    align:"center",
    dataIndex: 'reserve5'
   },
];


export const innerColumns: BasicColumn[] = [

  {
    title: '月份',
    align:"center",
    sorter: true,
    dataIndex: 'orderDate',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 7 ? text.substr(0,7) : text);
      return text;
    },
  },
  {
    title: '员工' ,
    align:"center",
    dataIndex: 'empId_dictText',
    width: 80,
  },

  {
    title: '型号',
    align:"center",
    dataIndex: 'machineModel_dictText',
    width:120,

  },
  {
    title: '合计',
    align:"center",
    dataIndex: 'reserve1'
  },
  {
    title: '下料',
    align:"center",
    dataIndex: 'blanking'
  },
  {
    title: '框架',
    align:"center",
    dataIndex: 'assemble'
  },
  {
    title: '运动件',
    align:"center",
    dataIndex: 'assemble1'
  },
  {
    title: '内线',
    align:"center",
    dataIndex: 'assemble2'
  },
  {
    title: '外线',
    align:"center",
    dataIndex: 'assemble3'
  },
  {
    title: '斜撑平台',
    align:"center",
    dataIndex: 'assemble4'
  },
  {
    title: '外壳',
    align:"center",
    dataIndex: 'assemble5'
  },
  {
    title: '配货',
    align:"center",
    dataIndex: 'distribution'
  },
  {
    title: '检验',
    align:"center",
    dataIndex: 'checkout'
  },
  {
    title: '打包',
    align:"center",
    dataIndex: 'pack'
  },
  {
    title: '发货',
    align:"center",
    dataIndex: 'shipment'
  },
  {
    title: '基础工资',
    align:"center",
    dataIndex: 'basicSalary'
  },
  {
    title: '全勤',
    align:"center",
    dataIndex: 'fullAttendance'
  },
  {
    title: '扣罚工资',
    align:"center",
    dataIndex: 'deduction'
  },
  {
    title: '其他项',
    align:"center",
    dataIndex: 'other'
  },
  {
    title: '预留',
    align:"center",
    dataIndex: 'reserve1'
  },

  {
    title: '预留',
    align:"center",
    dataIndex: 'reserve3'
  },
  {
    title: '预留',
    align:"center",
    dataIndex: 'reserve4'
  },
  {
    title: '预留',
    align:"center",
    dataIndex: 'reserve5'
  },
];


//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "月份",
      field: 'orderDate',
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM'
      },
      //colProps: {span: 6},
 	},
  {
    label: '员工',
    field: 'empId',
    component: 'UserSelect',
    componentProps: {
      rowKey: 'username',
      labelKey: 'realname',
      maxSelectCount: 10,
    },
    colProps: {span: 4},
  },

  {
    label: '明细',
    field: 'type',
    component: 'JSelectInput',

    componentProps: {
      options: [
        { label: '总数据', value: '0' },
        { label: '详情', value: '1' },
        { label: '未完成', value: '2' },
        { label: '已完成', value: '3' },
      ],
      defaultValue:'0'
    },
    colProps: { span: 4},
  },

];
//表单数据
export const formSchema: FormSchema[] = [
  // {
  //   field: 'machineModel',
  //   component: 'JCategorySelect',
  //   label: '型号',
  //   componentProps: {
  //     pcode: 'A01',
  //     multiple: true
  //   }
  // },
  // {
  //   label: '下料',
  //   field: 'blanking',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '框架',
  //   field: 'assemble',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '运动件',
  //   field: 'assemble1',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '内线',
  //   field: 'assemble2',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '外线',
  //   field: 'assemble3',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '斜撑平台',
  //   field: 'assemble4',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '外壳',
  //   field: 'assemble5',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '配货',
  //   field: 'distribution',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '检验',
  //   field: 'checkout',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '打包',
  //   field: 'pack',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '发货',
  //   field: 'shipment',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '基础工资',
  //   field: 'basicSalary',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '是否锁定 0 正常  -1 锁定',
  //   field: 'isLock',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '员工',
  //   field: 'empId',
  //   component: 'Input',
  // },
  // {
  //   label: '全勤',
  //   field: 'fullAttendance',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '扣罚工资',
  //   field: 'deduction',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '其他项',
  //   field: 'other',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '预留',
  //   field: 'reserve1',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '预留',
  //   field: 'reserve2',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '预留',
  //   field: 'reserve3',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '预留',
  //   field: 'reserve4',
  //   component: 'InputNumber',
  // },
  // {
  //   label: '预留',
  //   field: 'reserve5',
  //   component: 'InputNumber',
  // },

  {
    label: '月份',
    field: 'orderDate',
    component: 'MonthPicker',
    componentProps: {
      //不可选择日期
      disabledDate:(currentDate)=>{
        let date = dayjs(currentDate).format('YYYY-MM');
        let nowDate =  dayjs(new Date()).format('YYYY-MM');
        //当天不可选择
        if(date >= nowDate){
          return true;
        }
        return false;
      }
    },
  },


  {
    label: '员工',
    field: 'empId',
    component: 'UserSelect',
    componentProps: {
      rowKey: 'username',
      labelKey: 'realname',
      maxSelectCount: 10,
    },
    colProps: {span: 4},
  },

	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
  {
    label: '',
    field: 'type',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  machineModel: {title: '型号',order: 0,view: 'text', type: 'string',},
  orderDate: {title: '月份',order: 1,view: 'date', type: 'string',},
  blanking: {title: '下料',order: 2,view: 'number', type: 'number',},
  assemble: {title: '框架',order: 3,view: 'number', type: 'number',},
  assemble1: {title: '运动件',order: 4,view: 'number', type: 'number',},
  assemble2: {title: '内线',order: 5,view: 'number', type: 'number',},
  assemble3: {title: '外线',order: 6,view: 'number', type: 'number',},
  assemble4: {title: '斜撑平台',order: 7,view: 'number', type: 'number',},
  assemble5: {title: '外壳',order: 8,view: 'number', type: 'number',},
  distribution: {title: '配货',order: 9,view: 'number', type: 'number',},
  checkout: {title: '检验',order: 10,view: 'number', type: 'number',},
  pack: {title: '打包',order: 11,view: 'number', type: 'number',},
  shipment: {title: '发货',order: 12,view: 'number', type: 'number',},
  basicSalary: {title: '基础工资',order: 13,view: 'number', type: 'number',},
  isLock: {title: '是否锁定 0 正常  -1 锁定',order: 14,view: 'number', type: 'number',},
  empId: {title: '员工',order: 15,view: 'text', type: 'string',},
  fullAttendance: {title: '全勤',order: 17,view: 'number', type: 'number',},
  deduction: {title: '扣罚工资',order: 18,view: 'number', type: 'number',},
  other: {title: '其他项',order: 19,view: 'number', type: 'number',},
  reserve1: {title: '预留',order: 20,view: 'number', type: 'number',},
  reserve2: {title: '预留',order: 21,view: 'number', type: 'number',},
  reserve3: {title: '预留',order: 22,view: 'number', type: 'number',},
  reserve4: {title: '预留',order: 23,view: 'number', type: 'number',},
  reserve5: {title: '预留',order: 24,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}

